home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / demo3.zoo / demo / misc / set_emacs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-08  |  1.8 KB  |  55 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: set_emacs.c,v 4.3 88/06/23 09:40:47 bianchi Exp $
  9.     $Source: /tmp/mgrsrc/demo/misc/RCS/set_emacs.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/demo/misc/RCS/set_emacs.c,v $$Revision: 4.3 $";
  12.  
  13. /* print the current termcap entry on stdout (for EMACS) */
  14.  
  15. #include <stdio.h>
  16. #include "window.h"
  17.  
  18. #define ENTRY    "\'px|mgr|mgr teminal emulator:am:km:li#%d:co#%d:bs:cl=^L:ce=\\Ec:cd=\\EC:cm=\\E%%r%%d,%%dM:cs=\\E%%d,%%d%t:ve=\\Et:al=\\Ea:AL=\\E%%da:DL=\\E%%dd:dl=\\Ed:ic=\\EA:dc=\\EE:ta=^I:up=\\Eu:do=\\Ef:nd=\\Er:ku=\\E[A:kd=\\E[B:kr=\\E[C:kl=\\E[D:so=\\Ei:se=\\En:\'"
  19.  
  20. main(argc,argv)
  21. int argc;
  22. char **argv;
  23.    {
  24.    int b_flag=1;
  25.    int cols, rows;
  26.    char *rindex(), *getenv(), *getpass();
  27.    char *shell = getenv("SHELL");
  28.    char get[5];
  29.  
  30.    ckmgrterm( *argv );
  31.  
  32.    if (argc>1 && strcmp("-b",argv[1])==0)
  33.       b_flag=0;
  34.  
  35.    if (shell && rindex(shell,'/'))
  36.       shell = rindex(shell,'/')+1;
  37.  
  38.    sprintf(get,"%c%d%c",ESC,G_WINSIZE,E_GETINFO);
  39.    sscanf(getpass(get),"%d %d\n",&cols,&rows);
  40.    
  41.    if (b_flag && shell && strcmp(shell+strlen(shell)-3,"csh")==0) {        /* csh */
  42.       printf("set noglob;");
  43.       printf("setenv TERMCAP ");
  44.       printf(ENTRY,rows,cols);
  45.       printf(";unset noglob\n");
  46.       }
  47.    else                            /* /bin/sh */
  48.      {
  49.       printf("export TERMCAP\n");
  50.       printf("TERMCAP=");
  51.       printf(ENTRY,rows,cols);
  52.       putchar('\n');
  53.      }
  54.    } 
  55.